From 37bd4fbb2bf75bb06785d79a8d70161da2693db2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Fri, 9 Sep 2005 11:10:30 +0000 Subject: [PATCH] updating tests --- ChangeLog | 7 +++++++ tests/conversions.c | 43 ++++++++++++++++++++++++++++++------------ tests/srgb_to_lab_u8.c | 10 +++++----- tests/types.c | 2 +- 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index d6aa9ae..0c8cb01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-09-09 Øyvind Kolås + + * tests/conversions.c: (validate_conversion): do relative average + error calculations. + * tests/srgb_to_lab_u8.c: update values. + * tests/types.c: set a very low tolerance. + 2005-09-09 Øyvind Kolås * babl/babl-format.c: (create_name): Create shorter names when diff --git a/tests/conversions.c b/tests/conversions.c index f8703bd..6c1ba8d 100644 --- a/tests/conversions.c +++ b/tests/conversions.c @@ -7,9 +7,11 @@ int OK=1; -#define pixels 102400 +#define pixels 512 #define TOLERANCE 0.001 +#define ERROR_TOLERANCE 0.5 + double test[pixels * 4]; double r_interval (double min, double max) @@ -70,6 +72,8 @@ validate_conversion (BablConversion *conversion) Babl *fmt_source = BABL(conversion->source); Babl *fmt_destination = BABL(conversion->destination); + double error=0.0; + void *source; void *destination; double *destination_rgba_double; @@ -97,38 +101,53 @@ validate_conversion (BablConversion *conversion) { int i; - int log=0; + int cnt=0; for (i=0;iTOLERANCE) - { - if (!log) - log=1; - OK=0; - } - if (log && log < 5) + log=1; + } + if (0 && log && cnt < 5) { + /* enabling this code prints out the RGBA double values at various stages, + * which are used for the average relative error + */ + babl_log ("%s", conversion->instance.name); - babl_log ("\ttest: %2.3f %2.3f %2.3f %2.3f", test [i*4+0], + babl_log ("\ttest: %2.5f %2.5f %2.5f %2.5f", test [i*4+0], test [i*4+1], test [i*4+2], test [i*4+3]); - babl_log ("\tconversion: %2.3f %2.3f %2.3f %2.3f", destination_rgba_double [i*4+0], + babl_log ("\tconversion: %2.5f %2.5f %2.5f %2.5f", destination_rgba_double [i*4+0], destination_rgba_double [i*4+1], destination_rgba_double [i*4+2], destination_rgba_double [i*4+3]); - babl_log ("\tref_conversion: %2.3f %2.3f %2.3f %2.3f", ref_destination_rgba_double [i*4+0], + babl_log ("\tref_conversion: %2.5f %2.5f %2.5f %2.5f", ref_destination_rgba_double [i*4+0], ref_destination_rgba_double [i*4+1], ref_destination_rgba_double [i*4+2], ref_destination_rgba_double [i*4+3]); - log++; + cnt++; OK=0; } } + error /= pixels; + error *= 100; + + conversion->error = error; + if (error >= ERROR_TOLERANCE) + { + babl_log ("%s\terror:%f", conversion->instance.name, error); + OK = 0; + } } diff --git a/tests/srgb_to_lab_u8.c b/tests/srgb_to_lab_u8.c index 19b5c25..f973101 100644 --- a/tests/srgb_to_lab_u8.c +++ b/tests/srgb_to_lab_u8.c @@ -33,11 +33,11 @@ unsigned char source_buf [PIXELS*3]= unsigned char reference_buf [PIXELS*3]= { 0, 128, 128, - 135, 128, 127, - 254, 127, 128, - 135, 207, 195, - 222, 42, 210, - 81, 206, 20}; + 136, 128, 128, + 255, 128, 128, + 136, 208, 195, + 224, 42, 211, + 82, 207, 20}; unsigned char destination_buf [PIXELS*3]; diff --git a/tests/types.c b/tests/types.c index 8e76164..5c71ad0 100644 --- a/tests/types.c +++ b/tests/types.c @@ -3,7 +3,7 @@ int OK=1; -#define TOLERANCE 0.0046 +#define TOLERANCE 0.000000001 #define samples 2048 double test[samples]; -- 2.30.2